<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
    <script src="https://lib.baomitu.com/jquery/2.2.4/jquery.js"></script>
    <script src="https://lib.baomitu.com/vue/2.7.7/vue.js"></script>
    <script src="https://lib.baomitu.com/axios/latest/axios.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            width: 100vw;
            height: 100vh;
        }

        #mouse-position {
            position: fixed;
            width: 200px;
            height: 50px;
            background-color: #ff2d5166;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 100;
            text-align: center;
            line-height: 50px;
        }
    </style>
</head>

<body>
    <div id="mouse-position">

    </div>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        map.on("pointermove", evt => {// on每次触发都调用，once仅在第一次触发时调用
        // map.once("pointermove", evt => {
            console.log(evt)
            var { coordinate } = evt;
            $("#mouse-position").html(coordinate)
        })
    </script>
</body>

</html>